
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);


bind(sockfd, (struct sockaddr*)&addr, sizeof(addr));


struct sockaddr_in client_addr;
socklen_t len = sizeof(client_addr);
recvfrom(sockfd, buf, sizeof(buf), 0, (struct sockaddr*)&client_addr, &len);

int num = atoi(buf);
sprintf(buf, "%d", num * num);
sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr*)&client_addr, len);
